package cn.shutdown.demo.thread.suspend.lock01;

/**
 * @author jiangwujie
 * @date 2021/8/8
 */
public class SuspendAndResume {

    public static void main(String[] args) throws InterruptedException {
        Mythread mythread = new Mythread();
        //启动线程
        mythread.start();
        System.out.println("启动线程后" + mythread.getI());
        //休眠5秒
        Thread.sleep(5000);
        System.out.println("主线程休眠5秒后" + mythread.getI());
        //暂时线程
        mythread.suspend();
        System.out.println("子线程暂停"+mythread.getI());
        Thread.sleep(5000);
        System.out.println("子线程暂停5秒后"+mythread.getI());
        //恢复线程
        mythread.resume();
        System.out.println("子线程恢复" + mythread.getI());
        Thread.sleep(5000);
        System.out.println("子线程恢复5秒后" + mythread.getI());
        mythread.suspend();
        System.out.println("子线程暂停"+mythread.getI());
    }
}
